package com.feihao.zhou.mapper;

import com.feihao.zhou.bean.Card;
import com.feihao.zhou.bean.Person;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OneToOneMapper {
    //查询所有的card 及card对应的person:

    @Select("select * from card")
    @Results({
            @Result(column = "id", property = "id"),  //查询到的id给card的id属性赋值
            @Result(column = "number", property = "number"), //查询到的number给card 的number赋值

            @Result(
                    property = "person", javaType = Person.class,   // 将下面查询的person对象给 property=person的对象封装复制
                    column = "pid",  // 将上面查询到的pid  给到下面查询person作为条件
                    one = @One(select = "com.feihao.zhou.mapper.PersonMapper.selectById")
            )
    })
    abstract List<Card> selectALLCard();
}
